package info.niwota.pasta;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ViewNoteActivity extends Activity implements OnClickListener {

	private String getString(Bundle data, String key) {
		return (data == null ? null : data.getString(key));
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_LEFT_ICON);
		setContentView(R.layout.note_view);

		TextView viewTitle = (TextView) findViewById(R.id.note_view_title);
		TextView viewBody = (TextView) findViewById(R.id.note_view_body);
		Button btnOk = (Button) findViewById(R.id.note_view_ok);

		Bundle extras = getIntent().getExtras();
		String title = getString(extras, Note.EXTRA_TITLE);
		String body = getString(extras, Note.EXTRA_BODY);
		// String attach = getString(extras,Note.EXTRA_ATTACH);

		viewTitle.setText(title);
		viewBody.setText(body);
		//
		setTitle(R.string.title_note_view);
		getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
				R.drawable.icon);
		//
		setResult(Activity.RESULT_OK);
		//
		btnOk.setOnClickListener(this);
	}

	public void onClick(View v) {
		switch(v.getId()) {
		case R.id.note_view_ok:
			finish();
			return;
		}
	}
}
